#@layout()
#define css()
<style>
    .display-none{
        display:none;
    }
</style>
#end
#define script()
<script>
$(function(){


    $('.del-action').on('click', function () {
        if (confirm('确定要删除该分类吗？删除后不可恢复')) {
            var id = $(this).attr("data-id");
            ajaxGet("#(CPATH)/admin/article/doCategoryDel/" + id);
        }
    });

    $(".tflag").each(function () {
        $(this).on('click', function () {
            $("#flag").val($(this).text());
        })
    });
    $(".js-collapse").click(function(){
        $(this).toggleClass(" fa-chevron-down fa-chevron-up");
        $(this).parents('h4').next().toggle();
    })

})

</script>
#end
#define content()
    <section class="content-header">
        <div class="container-fluid">
            <div class="row">
                <div class="col-sm-6">

                    <div class="row mb-2">
                        <div class="col-sm-12">
                            <h1>
                                文章分类
                                <small data-toggle="tooltip" title="" data-placement="right"
                                       data-trigger="hover"><i class="nav-icon far fa-question-circle"></i></small>
                                <small> 首页 / 文章 / 文章分类</small>
                            </h1>
                        </div>
                    </div>
                </div>
            </div>

        </div><!-- /.container-fluid -->
    </section>

    <section class="content">

        <div class="row">
            <div class="col-lg-5">
                <div class="card card-outline card-primary">
                    <!-- form start -->
                    <form class=" form-setting autoAjaxSubmit" autocomplete="off"
                          action="#(CPATH)/admin/article/doCategorySave"
                          data-ok-href="#(CPATH)/admin/article/category"
                          data-ok-message="文章分类保存成功"
                          method="post">
                        <input type="hidden" name="category.id" value="#(category.id ??)">
                        <input type="hidden" name="category.type" value="category">
                        <div class="card-body">
                            <div class="form-group row">
                                <label class="col-sm-2 col-form-label"><span class="text-danger mr-2">*</span> 名称 </label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control" placeholder="取个适合的分类名称..." required
                                           value="#(category.title ??)" name="category.title">
                                </div>
                            </div>
                            <div class="form-group row">
                                <label class="col-sm-2 col-form-label"><span class="text-danger mr-2">*</span> 父级</label>

                                <div class="col-sm-9">
                                    <select class="form-control" name="category.pid">
                                        #if(category && category.pid == 0)
                                        <option value="0" selected>顶级</option>
                                        #else
                                        <option value="0">顶级</option>
                                        #end

                                        #for(c : categories)
                                        #if(category && category.pid == c.id)
                                        <option value="#(c.id)" selected>#(c.layerString) #(c.title)</option>
                                        #elseif(category && (category.id == c.id || category.isMyChild(c.id)))
                                        <option value="#(c.id)" disabled>#(c.layerString) #(c.title)</option>
                                        #else
                                        <option value="#(c.id)">#(c.layerString) #(c.title)</option>
                                        #end
                                        #end
                                    </select>
                                </div>
                            </div>

                            <div class="form-group row">
                                <label class="col-sm-2 col-form-label"> 固定连接 </label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control" placeholder="固定连接会显示在网址上..."
                                           value="#(category.slug ??)" name="category.slug">
                                    <p class="text-muted"> 该分类的固定连接，不填写默认为分类ID：<br /><span class="domainSpan">#option('web_domain')</span>/category/<span style="color: red">固定连接</span>  </p>
                                </div>
                            </div>

                            <div class="form-group row">
                                <label class="col-sm-2 col-form-label">排序</label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control" placeholder="此分类排序的序号"
                                           value="#(category.order_number ??)"
                                           name="category.order_number">
                                    <p class="text-muted"> 越小的数字越靠前，只在同级分类上影响。 </p>
                                </div>
                            </div>

                            <div class="form-group row">
                                <label class="col-sm-2 col-form-label">内容</label>
                                <div class="col-sm-9">
                                    <textarea rows="3" class="form-control"
                                              placeholder="..."
                                              name="category.content">#(category.content ??)</textarea>
                                </div>
                            </div>

                            <div class="form-group row">
                                <label class="col-sm-2 col-form-label">摘要</label>
                                <div class="col-sm-9">
                                    <textarea rows="3" class="form-control"
                                              placeholder="..."
                                              name="category.summary">#(category.summary ??)</textarea>
                                </div>
                            </div>


                            <div class="form-group row">
                                <label class="col-sm-2 col-form-label">图标</label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control" placeholder="给该分类设置图标"
                                           value="#(category.icon ??)" name="category.icon">
                                    <p class="text-muted"> 图标只用于前台显示，是否显示决定于模板。</p>
                                </div>
                            </div>


                            <div class="form-group row">
                                <label class="col-sm-2 col-form-label">标识</label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control" placeholder="展示标识"
                                           value="#(category.flag ??)" name="category.flag" id="flag">
                                    #if(flags && flags.size() > 0)
                                    <p class="text-muted">当前模板支持的展示标识有：
                                        #for(flag : flags ??)
                                        <a href="javascript:;" class="tflag">#(flag)</a>
                                        #end
                                    </p>
                                    #end
                                </div>
                            </div>


                            <div class="form-group row">
                                <label class="col-sm-2 col-form-label">模板</label>
                                <div class="col-sm-9">
                                    <select class="form-control" name="category.style">
                                        <option value="">默认（artlist.html）</option>
                                        #for(style : styles)
                                        <option value="#(style)" #selectedIf(category && category.style== style)>
                                            artlist_#(style).html
                                        </option>
                                        #end
                                    </select>
                                </div>
                            </div>

                            <div class="form-group row">
                                <label class="col-sm-2 col-form-label">是否推荐</label>
                                <div class="col-sm-9">
                                    <input type="checkbox" class="switchery" data-for="with_recommend" #checkedIf(category && category.with_recommend ??)>
                                    <input type="hidden" id="with_recommend" name="category.with_recommend" value="false">
                                </div>
                            </div>

                            <div class="form-group row">
                                <label class="col-sm-2 col-form-label">是否置顶</label>
                                <div class="col-sm-9">
                                    <input type="checkbox" class="switchery" data-for="with_top" #checkedIf(category && category.with_top ??)>
                                    <input type="hidden" id="with_top"  name="category.with_top" value="false">
                                </div>

                            </div>

                            <div class="form-group row">
                                <label class="col-sm-2 col-form-label">显示到菜单</label>
                                <div class="col-sm-9">
                                    <input type="checkbox" class="switchery" data-for="displayInMenu" #checkedIf(isDisplayInMenu)>
                                    <input type="hidden" id="displayInMenu" name="displayInMenu" value="false">
                                </div>
                            </div>

                            <!--装饰-->
                            <div class="accordion">
                                <div class="card " style="box-shadow: none;">
                                    <div class="card-header pl-2 border-bottom-light">
                                        <button type="button" class="btn btn-tool w-100  d-flex justify-content-between" data-toggle="collapse" data-target="#collapseOne">
                                            <h6 class="text-dark">装饰</h6>
                                            <span class="text-dark-50"><i class="fa fa-chevron-down" ></i></span>
                                        </button>
                                    </div>
                                    <div class="collapse" id="collapseOne">
                                        <div class="card-body p-4" >
                                            <div class="form-group row">
                                                <label class="col-sm-2 col-form-label">装饰图</label>
                                                <div class="col-sm-9">
                                                    <div class="jpress-image-browser">
                                                        <input type="hidden" name="category.ornament" value="#(category.ornament ??)"/>
                                                        <img src="#(category.ornament ??'/static/commons/img/nothumbnail.jpg')">
                                                        <div class="image-action">
                                                            <a class="image-delete"> <i class="fa fa-trash"></i></a>
                                                            <a class="image-edit"> <i class="fa fa-edit"></i></a>
                                                        </div>
                                                    </div>
                                                    <p class="text-muted"> </p>
                                                </div>
                                            </div>
                                            <div class="form-group row">
                                                <label class="col-sm-2 col-form-label">缩略图</label>
                                                <div class="col-sm-9">
                                                    <div class="jpress-image-browser">
                                                        <input type="hidden" name="category.thumbnail" value="#(category.thumbnail ??)"/>
                                                        <img src="#(category.thumbnail ?? '/static/commons/img/nothumbnail.jpg')">
                                                        <div class="image-action">
                                                            <a class="image-delete"> <i class="fa fa-trash"></i></a>
                                                            <a class="image-edit"> <i class="fa fa-edit"></i></a>
                                                        </div>
                                                    </div>
                                                    <p class="text-muted"> </p>
                                                </div>
                                            </div>
                                        </div>
                                    </div>

                                    <!-- /.card-body -->
                                </div>
                                <div class="card " style="box-shadow: none;">
                                    <div class="card-header pl-2 border-bottom-light">
                                        <button type="button" class="btn btn-tool w-100  d-flex justify-content-between" data-toggle="collapse" data-target="#collapseTwo">
                                            <h6 class="text-dark">SEO</h6>
                                            <span class="text-dark-50"><i class="fa fa-chevron-down" ></i></span>
                                        </button>
                                    </div>
                                    <div class="collapse" id="collapseTwo">
                                        <div class="card-body p-4" >
                                            <div class="form-group row">
                                                <label class="col-sm-2 col-form-label">标题</label>
                                                <div class="col-sm-9">
                                                    <input type="text" class="form-control" placeholder="SEO标题"
                                                           name="category.meta_title"
                                                           value="#(category.meta_title ??)">
                                                </div>
                                            </div>
                                            <div class="form-group row">
                                                <label class="col-sm-2 col-form-label">描述</label>

                                                <div class="col-sm-9">
                                    <textarea rows="3" class="form-control"
                                              placeholder="此内容会显示在搜索引擎的列表描述上..."
                                              name="category.meta_description">#(category.meta_description ??)</textarea>
                                                </div>
                                            </div>
                                            <div class="form-group row">
                                                <label class="col-sm-2 col-form-label">关键字</label>
                                                <div class="col-sm-9">
                                                    <input type="text" class="form-control" placeholder="多个关键字用逗号隔开"
                                                           name="category.meta_keywords"
                                                           value="#(category.meta_keywords ??)">
                                                </div>
                                            </div>
                                        </div>
                                    </div>

                                    <!-- /.card-body -->
                                </div>
                            </div>

                            <!--seo-->

                        </div>
                        <!-- /.card-body -->
                        <div class="card-footer">
                            <div class="offset-sm-2 col-sm-10 submit-block">
                                <div class="card-submit">
                                    <button type="submit" class="btn btn-primary">提交</button>
                                </div>
                            </div>
                        </div>
                        <!-- /.card-footer -->
                    </form>
                </div>
            </div>
            <div class="col-lg-7">
                <div class="card card-outline card-primary">



                    <div class="card-body p-0  ">

                        <table class="table table-striped">
                            <tbody>
                            <tr>
                                <th style="width: 40%">标题</th>
                                <th>固定链接</th>
                                <th>描述</th>
                                <th>排序</th>
                            </tr>
                            #for(category : categories)
                            <tr>
                                <td>
                                    <strong>
                                        <a href="#(category.url ??)" target="_blank">
                                            #(category.layerString) #(category.title)
                                        </a>
                                        （#(category.count ?? 0)）
                                    </strong>
                                    <div class="jp-action-card">
                                        <div class="jp-action-body">
                                            <a href="#(CPATH)/admin/article/category/#(category.id)">编辑</a> |
                                            <a href="javascript:;" class="del-action red-action" data-id="#(category.id)">删除</a> |
                                            <a href="#(category.url ??)" target="_blank" class="red-action">访问</a>
                                        </div>
                                    </div>
                                </td>
                                <td>#(category.slug ??)</td>
                                <td>#(category.content ??)</td>
                                <td>#(category.order_number ??)</td>
                            </tr>
                            #else
                            <tr class="nodata"><td colspan="999">暂无数据</td> </tr>
                            #end
                            </tbody>
                        </table>
                    </div>
                    <!-- /.card-body -->
                    <div class="card-footer">
                        <div class="row">
                            <div class="col-sm-12">
                            </div>
                        </div>
                    </div>
                </div>
                <!-- /.card -->
            </div>
            </div>
    </section>


#end
